from api.TokenApi import TokenApi
from api.AssignUploadUrlFirstTrueApi import AssignUploadUrlFirstTrueApi
from api.AssignUploadUrlTwoFalseApi import AssignUploadUrlTwoFalseApi
from api.PackageBotApi import PackageBotApi
from api.PackageJsonApi import PackageJsonApi
from api.CreateApi import CreateApi
from api.GetPackageBotApi import GetPackageBotApi
from api.DetailApi import DetailApi
from api.ListApi import ListApi
import uuid

# token_api = TokenApi()
# user_name = '17336606653'
# password = 'pBuXAJx2WmzMu6FbrWsA3DhwrI/q+tIplYVmpEfyevzHxNgUZ6oMDpXNVTn/q1GMcN3s1AD31HcjHk4OWC/AChhprGLqLBLYxEmjRmaC3cxod+AuGnWuvMARODV9gFj5qkxxSiTfCtQsAmWLzk440hmWoHSkWaKd+U9XvStY5A8='
# token_info = token_api.token(user_name, password)
# access_token = token_info.get('access_token')
# print(access_token)
# t_user_name = '19076196325'
# t_password = 'pBuXAJx2WmzMu6FbrWsA3DhwrI/q+tIplYVmpEfyevzHxNgUZ6oMDpXNVTn/q1GMcN3s1AD31HcjHk4OWC/AChhprGLqLBLYxEmjRmaC3cxod+AuGnWuvMARODV9gFj5qkxxSiTfCtQsAmWLzk440hmWoHSkWaKd+U9XvStY5A8='
# t_token_info = token_api.token(t_user_name, t_password)
# t_access_token = t_token_info.get('access_token')
#
# print(access_token, t_access_token)

# f3754420-82e4-4fc1-bcb6-fd4a7d66f195 d2306f0d-45db-4172-80c7-607f96653c9d
#
# appId = str(uuid.uuid4())
# print(appId)
appId = '90eff8e4-9f01-4061-a67a-793f18d91111'
name = '新的項目喔'

t_access_token = '37e87789-9c8a-4fdd-a121-df69a6f5af6b'
assign_upload_url_first_true_api = AssignUploadUrlFirstTrueApi()
first_info = assign_upload_url_first_true_api.assign_upload_url(t_access_token, appId)
bot_uploadUrl = first_info.get('data').get("uploadUrl")

assignUploadUrlTwoFalseApi = AssignUploadUrlTwoFalseApi()
first_info = assignUploadUrlTwoFalseApi.assign_upload_url(t_access_token, appId)
json_uploadUrl = first_info.get('data').get("uploadUrl")
fileKeyMd5 = first_info.get('data').get("fileKeyMd5")

packageBotApi = PackageBotApi()
packageBotApi.package_bot(bot_uploadUrl)

packageJsonApi = PackageJsonApi()
packageJsonApi.save(json_uploadUrl, appId, name)

createApi = CreateApi()
createApi.create(t_access_token, appId, fileKeyMd5, name)

# detailApi = DetailApi()
# detailApiInfo = detailApi.detail(t_access_token, appId)
# detailApiInfo
# packageBotUrl = detailApiInfo.get('data').get("packageBotUrl")
# # 下载
# getPackageBotApi = GetPackageBotApi()
# getPackageBotApi.get_package_bot(packageBotUrl)
